package com.bangcommunity.bbframe.common.base;

public enum ResultCode {

    SUCCESS("20000", "成功"), NOTLOGIN("40100", "未登录"), NOTALLOWED("40300", "没有权限"), OTHER("50000", "系统错误");

    private String code;
    private String desc;

    ResultCode(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static ResultCode fromCode(String code) {
        ResultCode[] values = ResultCode.values();
        if (null != values) {
            for (ResultCode resultCode : values) {
                if (resultCode.getCode().equals(code)) {
                    return resultCode;
                }
            }
        }
        return null;
    }

}